package com.lxl.commons.mapper.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.workbench.entity.Library;
import javax.servlet.jsp.jstl.sql.Result;
import java.util.ArrayList;
import java.util.List;

/**
 * 图书馆的Result转化成List集合
 * @author 北上寻海
 */
public class LibraryMapperImpl implements IMapper {
    @Override
    public List<Library> mapper(Result result) {
        List<Library> list = new ArrayList<>();
        if(result.getRowCount()!=0){

            for (int i = 0 ;i<result.getRowCount();i++){
                Library library = new Library();
                library.setId((String)result.getRowsByIndex()[i][0]);
                library.setLibraryName((String)result.getRowsByIndex()[i][1]);
                library.setLibraryLocation((String)result.getRowsByIndex()[i][2]);
                library.setLibraryCurator((String)result.getRowsByIndex()[i][3]);
                list.add(library);
            }
        }else {
            list = null;
        }
        return list;
    }
}
